/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.chl.vrangogym.persistence.entities.keys;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Ulken
 */
public class BookingPK implements Serializable {

    private static final long serialVersionUID = 1L;
    private String booker;
    @Temporal(TemporalType.DATE)
    private Date workoutSession;

    public BookingPK() {
    }

    public BookingPK(String user, Date workoutSession) {
        this.booker = user;
        this.workoutSession = workoutSession;
    }
    
    /**
     * Immutable composite key
     */

    public String getBooker() {
        return booker;
    }

    public Date getWorkoutSession() {
        return workoutSession;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final BookingPK other = (BookingPK) obj;
        if ((this.booker == null) ? (other.booker != null) : !this.booker.equals(other.booker)) {
            return false;
        }
        if (this.workoutSession != other.workoutSession && (this.workoutSession == null || !this.workoutSession.equals(other.workoutSession))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 71 * hash + (this.booker != null ? this.booker.hashCode() : 0);
        hash = 71 * hash + (this.workoutSession != null ? this.workoutSession.hashCode() : 0);
        return hash;
    }

}
